import request from '@/utils/request'

const api_name = 'knowledgeAdmin/xtyh'

export default {
  GetMenus(params) {
    return request({
      url: 'knowledgeAdmin/xtyh/menu',
      method: 'get',
      params,
    })
  },
  getPageList(params) {
    return request({
      url: `${api_name}/list`,
      method: 'get',
      params,
    })
  },
  getById(id) {
    return request({
      url: `${api_name}/info/${id}`,
      method: 'get',
    })
  },

  save(user) {
    return request({
      url: `${api_name}/save`,
      method: 'post',
      data: user,
    })
  },

  updateById(user) {
    return request({
      url: `${api_name}/update`,
      method: 'put',
      data: user,
    })
  },
  getAssign(userId) {
    return request({
      url: `${api_name}/toAssign/${userId}`,
      method: 'get',
    })
  },
  saveAssign(userId, roleId) {
    return request({
      url: `${api_name}/doAssign`,
      method: 'post',
      params: { userId, roleId },
    })
  },
  removeRows(idList) {
    return request({
      url: `${api_name}/delete`,
      method: 'delete',
      data: idList,
    })
  },

  resetUserPwd(idList) {
    return request({
      url: `${api_name}/resetPwd`,
      method: 'put',
      data: idList,
    })
  },

  equlasOldPwd(oldPassword) {
    return request({
      url: `${api_name}/equlasOldPwd`,
      method: 'put',
      params: { oldPassword },
    })
  },

  updatePwd(data){
    return request({
      url: `${api_name}/updatePwd`,
      method: 'put',
      data,
    })
  },
  
  nameIsExist(name){
    return request({
      url: `${api_name}/nameIsExist/${name}`,
      method: 'get',
    })
  }
}
